﻿@using MvcApplication4.Models
@model IEnumerable<tb_Vacinacao>
@{
    ViewBag.Title = "Vacinação";
    //Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>Vacinações Aplicadas</h2>
<br />
    @Html.ActionLink("Cadastrar Vacinação", "Create","CadastroVacinacao")
<br />
<br/>
    @{
        Html.Syncfusion().Grid<tb_Vacinacao>("GenericListGrid")
            .Datasource(Model)
            .Caption("Detalhes da Vacinação")
            .EnablePaging()
            .EnableSorting()
            .AutoFormat(Skins.Turquoise)
       .AllowResizing(true)
       .ClientSideEvents(e => e.OnToolbarClickEvent("pdf_export"))
       .ToolBar(toolbar =>
       {
           toolbar.Add(GridToolBarItems.ExcelExport, "Excel")
                  .Add(GridToolBarItems.WordExport, "Word")
                  .Add(GridToolBarItems.PDFExport, "PDF");
       })
            .Mappers(map =>
            {
                map.ExportExcelAction("ExportToExcel")
                   .ExportWordAction("ExportToWord")
                   .ExportPdfAction("ExportToPDF");
            })
       .EnableFiltering()
              
            .Column(cols =>
                {
                    cols.Add(c => c.ID_Vacinacao).HeaderText("ID").TextAlign(Syncfusion.Mvc.Grid.TextAlignment.Right).Width(110);
                    cols.Add(c => c.tb_Paciente.Nome_Paciente).HeaderText("Nome Paciente");
                    cols.Add(c => c.tb_Funcionario.Nome_Funcionario).HeaderText("Nome Funcionário").TextAlign(Syncfusion.Mvc.Grid.TextAlignment.Right);
                    cols.Add(c => c.tb_UBS.Nome_UBS).HeaderText("Nome UBS").TextAlign(Syncfusion.Mvc.Grid.TextAlignment.Right).Width(90);
                    cols.Add(c => c.tb_Vacina.Nome_Vacina).HeaderText("Nome Vacina").TextAlign(Syncfusion.Mvc.Grid.TextAlignment.Right).Width(80);
                    cols.Add(c => c.ID_Lote).HeaderText("Lote");
                    //cols.Add(c => c.Hora).HeaderText("Hora");
                    cols.Add(c => c.Data_Vacinacao).HeaderText("Data");
                    cols.Add("Editar").HeaderText("Editar?").Format("<a href=/CadastroVacinacao/Edit/{ID_Vacinacao}>Editar</a>").Width(50);
                    cols.Add("Deletar").HeaderText("Deletar?").Format("<a href=/CadastroVacinacao/Delete/{ID_Vacinacao}>Deletar</a>").Width(60);
                }).Render();

    }
    
    <script type="text/javascript">

        function pdf_export(sender, args) {



            if (args._currentItemId == sender._ID + 'pdf_export'

            || args._currentItemId == sender._ID + 'word_export'

            || args._currentItemId == sender._ID + 'excel_export') {

                var _VisibleColumns = new Array();

                $.each(sender.get_VisibleColumns(), function (index, Column) {

                    if (Column.Name == "Editar") {

                        Column.Visible = false; //removing columns for export

                    }

                    if (Column.Name == "Deletar") {

                        Column.Visible = false; //removing columns for export

                    }

                    if (Column.Visible == true) {

                        _VisibleColumns.push(Column); //visible columns

                    }

                });

                sender.set_VisibleColumns(Sys.Serialization.JavaScriptSerializer.serialize(_VisibleColumns)); //Set visible columns.

            }

        }

 

</script>